package com.tool.btn;

import com.tool.role.RoleData;
import com.tool.tcpimg.UIUtils;
import org.come.Frame.ZhuFrame;
import org.come.Jpanel.GetLiangHaoTwoJpanel;
import org.come.Jpanel.MyLiangHaoJpanel;
import org.come.Jpanel.PaintLiangHaoJpanel;
import org.come.Jpanel.ZhuJpanel;
import org.come.entity.SellLiangHaoBase;
import org.come.socket.Agreement;
import org.come.socket.SendMessageUntil;
import org.come.until.FormsManagement;
import org.come.until.GsonUtil;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.math.BigDecimal;

public class LiangHaoPaiBtn extends MoBanBtn {
    //0上 1下 2顶 3底
    int typeBtn;
    private GetLiangHaoTwoJpanel jpanel;
    private PaintLiangHaoJpanel paintLiangHaoJpanel;
    private int p;

    public LiangHaoPaiBtn(String iconpath, int type, Color[] colors,
                          Font font, String text, Integer typeBtn, GetLiangHaoTwoJpanel jpanel) {
        // TODO Auto-generated constructor stub
        super(iconpath, type, colors);
        this.setText(text);
        this.typeBtn = typeBtn;
        this.setFont(UIUtils.TXT_hyzjt18);
        setVerticalTextPosition(SwingConstants.CENTER);
        setHorizontalTextPosition(SwingConstants.CENTER);
        this.jpanel = jpanel;
    }

    public LiangHaoPaiBtn(String iconpath, int type, String text, Integer typeBtn, PaintLiangHaoJpanel paintLiangHaoJpanel) {
        // TODO Auto-generated constructor stub
        super(iconpath, type);
        this.setText(text);
        this.typeBtn = typeBtn;
        this.setFont(UIUtils.TEXT_HY16);
        setVerticalTextPosition(SwingConstants.CENTER);
        setHorizontalTextPosition(SwingConstants.CENTER);
        this.paintLiangHaoJpanel = paintLiangHaoJpanel;
    }


    @Override
    public void chooseyes() {

    }

    @Override
    public void chooseno() {

    }

    @Override
    public void nochoose(MouseEvent e) {
        //获取当前选中的位置
        if(this.typeBtn == 1){       //我的竞拍
            FormsManagement.showForm(641);
        }else if(this.typeBtn == 2){  //点击我的竞拍
            this.jpanel.changeContent();
        }else if(this.typeBtn == 3){  //点击信笺
            FormsManagement.showForm(704);
        }else if(this.typeBtn == 4){     //改变靓号配色
            int selType = this.paintLiangHaoJpanel.getSelectType();
            BigDecimal payXy = new BigDecimal (this.paintLiangHaoJpanel.getLabPayXy().getText());
            BigDecimal myXu = RoleData.getRoleData().getLoginResult().getCodecard();
             if(myXu.compareTo(payXy)<0){
                 ZhuFrame.getZhuJpanel().addPrompt2("你的仙玉不足："+payXy);
                 return;
            }
            SellLiangHaoBase newSellLiangHaoBase = new SellLiangHaoBase();
            newSellLiangHaoBase.setAucPrice(payXy.intValue());
            newSellLiangHaoBase.setType(selType);
            String mes = Agreement.getAgreement().selllianghaoAgreement("CHANGETYPE|" + GsonUtil.getGsonUtil().getgson().toJson(newSellLiangHaoBase));
            SendMessageUntil.toServer(mes);
        }
    }
}
